/*
 * QFontAdapter.h  0.4.0 / Nov 17, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
#ifndef QFONTADAPTER_H
#define QFONTADAPTER_H

#include <QFont>

#include "Cute4jCore.h"

// QFontAdapter Class. ---------------------------------------------------------

/*!
 * \brief QFont Adapter.
 *
 * \author Slobodan Vrkacevic
 * \version 0.4.0
 */
class CUTE4J_EXPORT QFontAdapter : public QFont
{
protected:
  QFontAdapter(jstring name, jint style, jint size);
  QFontAdapter(const QFont &font);
public:
  static void initialize(JNIEnv *env, jclass cls);
  static QFontAdapter *toQFont(JNIEnv *env, jobject font);
  static QFontAdapter *toQFont(jobject font);
  static jobject toJFont(JNIEnv *env, jclass fontClass, const QFont &font);
  static jobject toJFont(const QFont &font);
public: // native calls
  static jlong newInstance(JNIEnv *env, jobject obj, jstring name, jint style,
                           jint size);
  static jlong newFontMetricsInstance(JNIEnv *env, jobject obj,
                                      jlong fontPonter);
  static jstring getDefaultFontName(JNIEnv *env, jclass cls);
private:
  static jint fontStyle(const QFont &font);
private:
  static jclass sm_fontClass;
  static jfieldID sm_lockFID;
  static jmethodID sm_constructorMID;
  static jmethodID sm_createMID;
  static jmethodID sm_createFontMetricsMID;
  static jmethodID sm_getFontPointerMID;
};

// Macro Definitions. ----------------------------------------------------------

#define qFontCast(fontPonter) (reinterpret_cast<QFontAdapter *>(fontPonter))
#define qFontAdapter qFontCast(fontPonter)

#endif //QFONTADAPTER_H
